import { Color, Label, Sprite } from "cc"
import { TbRoot } from "../../platform/excel_table/TbRoot"
import { UIComponent } from "../../platform/ui/UIComponent"
import { bind } from "../../platform/ui/UIDecorator"
import { Tb_Monster, Tb_MonsterContainer } from "../tb/TB_Monster"
import { BuffMgr } from "./BuffMgr"
import { PropSet } from "./PropertySet"
import { Skill } from "./Skill"
import { SkillMgr } from "./SkillMgr"
import { Enum_PropType } from "./Enum_PropType"
import { BattleRoom } from "./BattleRoom"
import { BattleObj } from "./BattleObj"
import { BehaviorScript } from "./BehaviorScript"
import { CommonMonsterBehaviorScript } from "./behavior/CommonMonsterBehaviorScript"

export default class Monster extends BattleObj{

    @bind(Label)
    show_id:Label

    cfg:Tb_Monster
    behaviorScript:BehaviorScript = new CommonMonsterBehaviorScript(this)
    init(){
        let container =TbRoot.ins.getTbContainer(Tb_MonsterContainer)
        this.cfg = container.getCfgById(this.cfgId)
        let speed = 200;
        let scale = 1;
        let color = "FFFFFF";
        if(this.cfg.level == 1){//小怪
            speed = 100;
            scale = 0.6
        }else if(this.cfg.level == 2){//中怪
            speed = 150;
            color = "522929";
        }else if(this.cfg.level == 3){//精英怪
            speed = 200;
            scale = 1.8
            color = "FF0F0F";
        }
        //速度
        this.propSet.set(Enum_PropType.Speed, speed);
        this.node.setScale(scale, scale, 1);
        let colorObj = Color.WHITE;
        Color.fromHEX(colorObj,color);
        this.node.getComponent(Sprite).color = colorObj

    }

    releaseSkill(){

    }


    update(dt: number): void {
        if(this.isDead()) {
            return;
        }
        //行为脚本，因为很多怪物可能行为相同，因此，将行为脚本抽离出来
        this.behaviorScript.update(dt);
    }
}